<!--Generate by Kevin's CodeBuilder 2021-09-12 16:09:23 -->
<!--请注意！这里是页面片段，定义的标签ID，js变量不要与index.html列表页面重复-->
<!--如果是较复杂的页面，可以修改window的数据类型(dataType: iframe),然后将form.html改为完整的页面,实现iframe隔离，需要修改curdObj的访问方式为parent.curdObj-->
<div id="form_container" class="form_container">
    <!--利用隐藏的id标签区分是新增/编辑-->
    <input type="hidden" id="id" name="id" th:value="*{id}"/>
    <table class="k_form_table">
			<tr>
				<td class="label label20">[(${Lang.user_orgId})]</td>
				<td><input id="orgId" name="orgId" class="form_input form_input50 k_box_size" type="text"/></td>
			</tr>
			<tr>
				<td class="label label20">[(${Lang.user_userAccount})]</td>
				<td><input id="userAccount" name="userAccount" class="form_input form_input50 k_box_size" type="text"/></td>
			</tr>
			<tr>
				<td class="label label20">[(${Lang.user_userName})]</td>
				<td><input id="userName" name="userName" class="form_input form_input50 k_box_size" type="text"/></td>
			</tr>
			<tr>
				<td class="label label20">[(${Lang.user_userPwd})]</td>
				<td><input id="userPwd" name="userPwd" class="form_input form_input50 k_box_size" type="password"/></td>
			</tr>
			<tr>
				<td class="label label20">[(${Lang.user_userStatus})]</td>
				<td>
					<label class="k_radio_label k_radio_anim">
						<input type="radio" name="userStatus"  value="1"/>
						<i class="k_radio_i"></i>正常
					</label>
					<label class="k_radio_label k_radio_anim">
						<input type="radio" name="userStatus" value="0"/>
						<i class="k_radio_i"></i>禁用
					</label>
				</td>
			</tr>
			<tr>
				<td class="label label20">[(${Lang.user_userPhone})]</td>
				<td><input id="userPhone" name="userPhone" class="form_input form_input50 k_box_size" type="text"/></td>
			</tr>
			<tr>
				<td class="label label20">[(${Lang.user_userEmail})]</td>
				<td><input id="userEmail" name="userEmail" class="form_input form_input50 k_box_size" type="text"/></td>
			</tr>
			<tr>
				<td class="button_td" colspan="2" style="padding-top:15px">
					<button id="button_submit" class="k_common_button"><i class="fa fa-floppy"></i> <span>[(${Lang.common_save})]</span></button>
					<button id="button_goback" class="k_common_button"><i class="fa fa-reply-all"></i><span>[(${Lang.common_goback})]</span></button>
				</td>
			</tr>
    </table>
</div>
<script type="application/javascript" th:src="@{/static/lib/vue.min.js}"></script>
<script type="application/javascript" th:inline="javascript">

    $B.DomUtils.onDomLoaded(function () {
		var vueForm,
				entityJson = [(${entityJson})],
				$form = document.getElementById("form_container"),
				idValue = document.getElementById("id").value,  //用于区分新增,编辑
				isUpated = idValue !== "";


        /***定义验证字段 ，配置监听回调等***/
        var formOpt = {
            verifyOnChange: true,
            verify: {
				orgId:[{rule:'require',"label":"请选择机构"}],
				userAccount:['require','wchar'],
				userName:['require','chchar'],
				userPhone:'phone',
				userEmail:'email'
            }
        };
		if(isUpated){
			document.getElementById("userPwd").parentNode.parentNode.style.display = "none";
		}else{
			formOpt.verify.userPwd = ['require','password'];
		}
        /**自定义控件配置,请参考Bui表单控件***/
        var diyCtls = {
			orgId:{
				ctl: 'Combox',
				opts: {
					url: $B.getHttpHost()+"org/query",
					isTree: true,
					valueModel:'',
					inputImdSearch: true,
					multiple: false,
					readOnly: true,
					onSelected: function (data) {
						console.log(data);
					},
					onloaded: function (data) {
						console.log(data);
					}
				}
			}
		} ;
		if(isUpated){
			diyCtls.orgId.opts.selectedValue = {id:entityJson.orgId,text:entityJson.extFeildsMap.orgName};
		}
        vueForm = $B.vueForm( $form,entityJson,diyCtls,formOpt);

        /***当窗口关闭时候，销毁vueForm**/
        curdObj.setVueForm(vueForm);

        /**绑定事件**/
        $B.DomUtils.click(document.getElementById("button_goback"), function () {
            curdObj.closeWindow();
        });
        $B.DomUtils.click(document.getElementById("button_submit"), function () {
            if(vueForm.toVerify()){
                var prs = vueForm.toJSON();
                if(isUpated){
                	delete prs.userPwd;
					curdObj.update(prs,this);
                }else{
					curdObj.add(prs,this);
                }
            }else{
                $B.error("[(${Lang.common_verify_err})]",1.5);
            }
        });
    });
</script>
